//
//  EquipmentListCell.m
//  PPScaleDemo
//
//  Created by 彭思远 on 2021/3/11.
//

#import "EquipmentListCell.h"
#import "ConfigNetworkViewController.h"

@interface EquipmentListCell()
@property (weak, nonatomic) IBOutlet UILabel *cellNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *cellMacLabel;
@property (weak, nonatomic) IBOutlet UILabel *cellSNLabel;
@property (weak, nonatomic) IBOutlet UILabel *cellSSIDLabel;
@property (weak, nonatomic) IBOutlet UIButton *unbindBtn;
@property (weak, nonatomic) IBOutlet UIButton *configBtn;

@property (nonatomic, strong) DeviceModel *model;
@property (nonatomic, copy) void(^userAction)(BOOL isUnbind);

@end

@implementation EquipmentListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)fillWithModel:(DeviceModel *)model{
    
    self.cellNameLabel.text = model.deviceName;
    self.cellMacLabel.text = model.deviceMac;
    self.cellSNLabel.text = model.deviceSN;
    self.cellSSIDLabel.text = model.deviceSSID;
    self.configBtn.hidden = YES;

    if ([model.deviceName isEqualToString:kBLEDeviceHealthScale5] ||
        [model.deviceName isEqualToString:kBLEDeviceHealthScale6] ) {
        self.configBtn.hidden = NO;
    }
    self.model = model;
}

- (void)handleUserAction:(void(^)(BOOL isUnbind))handler{
    self.userAction = handler;
}

- (IBAction)unbindBtnClick:(id)sender {
    if (self.userAction) {
        self.userAction(YES);
    }
}

- (IBAction)configBtnClick:(id)sender {
    if (self.userAction) {
        self.userAction(NO);
    }
    
}

@end
